<?
include("session.php");
?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="/webkit/utils/jquery.js"></script>
<script type="text/javascript" src="/webkit/dialog/import.js"></script>
<script type="text/javascript" src="/webkit/datepicker/WdatePicker.js"></script>
<script type="text/javascript" src="/webkit/charts/import.js"></script>
<link type="text/css" rel="stylesheet" href="page.css"/>
<style>	input {vertical-align:middle} </style>
</head>
<body onload="show_report_charts()">

<table width=100% height=100% cellspacing=0 cellpadding=0>
	<tr bgcolor="#eeeeee">
	<form name=f>
	<td height=30>&nbsp;
    统计类型：<select id="count_type"><option value='1'>定单数</option><option value='2'>消费金额</option></select>　时间范围：<input type="text" id="date_start" name="date_start" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" size="10"> - <input type="text" id="date_end" name="date_end" onClick="WdatePicker({readOnly:true, skin:'whyGreen',dateFmt:'yyyy-MM-dd'})" size="10">　
	<input type="button" value="图表统计" onclick="show_report_charts()">　　
    </td>
	</tr>
	<tr>
	<td>
		<table width=100% height=100% id="chartsTable">
		<tr><td id="chartContainer1" width=50%></td><td id="chartContainer2"  width=50%></td></tr>
		<tr><td id="chartContainer3" width=50%></td><td id="chartContainer4"  width=50%></td></tr>
		</table>
	</td>
	</form>
	</tr>
</table>

<script type="text/javascript">

	var chart1 = new FusionCharts("/webkit/charts/Pie3D.swf",  "chart1", "100%", "100%", "0", "1" );     
	var chart2 = new FusionCharts("/webkit/charts/Pie3D.swf",  "chart2", "100%", "100%", "0", "1" );     
	var chart3 = new FusionCharts("/webkit/charts/Column3D.swf", "dayReport", "100%", "100%", "0", "1"); 
	var chart4 = new FusionCharts("/webkit/charts/Line.swf",  "timeReport", "100%", "100%", "0", "1" );   

	function show_report_charts() {

		$.get("report_query.php?action=area_report"+ get_report_condition(), function(data){
			eval("var json = "+data);
			chart1.setJSONData(json);
			chart1.render('chartContainer1');  
		});

		$.get("report_query.php?action=source_report"+ get_report_condition(), function(data){
			eval("var json = "+data);
			chart2.setJSONData(json);
			chart2.render('chartContainer3');  
		});

		$.get("report_query.php?action=month_report"+ get_report_condition(), function(data){
			eval("var json = "+data);
			chart3.setJSONData(json);
			chart3.render('chartContainer2');  
			get_day_report('<?echo date("Y-m-d")?>');
		});
	}

	function get_day_report(dt) {
		$.get("report_query.php?action=day_report&count_type="+ $("#count_type").val()+"&dt="+dt, function(data){
			eval("var json = "+data);
			chart4.setJSONData(json);
			chart4.render('chartContainer4');  
		});
	}


	function get_report_condition() {
		var str = "&count_type="+ $("#count_type").val();
		if($("#date_start").val()!='' && $("#date_end").val()!='') {
			str += "&date_start="+ $("#date_start").val() + "&date_end=" + $("#date_end").val();
		}
		return str;
	}

  
</script>
</body>
</html>
